package com.mytest;

import java.lang.reflect.Field;
import java.lang.reflect.Method;

import com.test.reflect.Book;

public class ReflectionTest {
	public static void main(String[] args) throws Exception {
		Class cls = Class.forName("com.test.reflect.Book");
		System.out.println(cls.getFields().toString());
		
		Field[] fields = cls.getDeclaredFields();
		for (int i = 0; i < fields.length; i++) {
			System.out.println(fields[i].toString());
		}
		System.out.println("-------------------------------------------------------------------------------------");
		Method[] methods = cls.getMethods();
		for(int i = 0; i < methods.length; i++) {
			System.out.println(methods[i].toString());
		}
		System.out.println("-------------------------------------------------------------------------------------");
		
		Book book = (Book) cls.getConstructor(new Class[]{}).newInstance();
		System.out.println(book.getName());
	}
}
